//
//  MyViewController.m
//  Hai
//
//  Created by 千金贷 on 16/2/23.
//  Copyright © 2016年 wangzijian. All rights reserved.
//

#import "SNCalendarViewController.h"
#import "SJAvatarBrowser.h"
#import "UIImageView+WebCache.h"

@interface SNCalendarViewController ()

@end

@implementation SNCalendarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"日历";
    self.automaticallyAdjustsScrollViewInsets = NO;
    _calendar.dataSource = self;
    _calendar.delegate = self;
    [_calendar reloadData];
    _calendar.appearance.caseOptions = FSCalendarCaseOptionsHeaderUsesUpperCase|FSCalendarCaseOptionsWeekdayUsesUpperCase;
    _calendar.backgroundColor = [UIColor whiteColor];
    JTMaterialSwitch *periodStartSwitch = [[JTMaterialSwitch alloc] initWithSize:JTMaterialSwitchSizeNormal
                                                 style:JTMaterialSwitchStyleDefault
                                                 state:JTMaterialSwitchStateOn];
    periodStartSwitch.tag=101;
    periodStartSwitch.center = CGPointMake(kScreenWidth-40, 76);
    [periodStartSwitch addTarget:self action:@selector(stateChanged:) forControlEvents:UIControlEventValueChanged];
    [self.bottomView addSubview:periodStartSwitch];
    
    JTMaterialSwitch *periodEndSwitch = [[JTMaterialSwitch alloc] initWithSize:JTMaterialSwitchSizeNormal
                                                                           style:JTMaterialSwitchStyleDefault
                                                                           state:JTMaterialSwitchStateOn];
    periodEndSwitch.tag=102;
    periodEndSwitch.center = CGPointMake(kScreenWidth-40, 127);
    [periodEndSwitch addTarget:self action:@selector(stateChanged:) forControlEvents:UIControlEventValueChanged];
    [self.bottomView addSubview:periodEndSwitch];
    JTMaterialSwitch *aaStartSwitch = [[JTMaterialSwitch alloc] initWithSize:JTMaterialSwitchSizeNormal
                                                                           style:JTMaterialSwitchStyleDefault
                                                                           state:JTMaterialSwitchStateOn];
    aaStartSwitch.tag=103;
    aaStartSwitch.center = CGPointMake(kScreenWidth-40, 229);
    [aaStartSwitch addTarget:self action:@selector(stateChanged:) forControlEvents:UIControlEventValueChanged];
    [self.bottomView addSubview:aaStartSwitch];
    JTMaterialSwitch *byStartSwitch = [[JTMaterialSwitch alloc] initWithSize:JTMaterialSwitchSizeNormal
                                                                           style:JTMaterialSwitchStyleDefault
                                                                           state:JTMaterialSwitchStateOn];
    byStartSwitch.tag=104;
    byStartSwitch.center = CGPointMake(kScreenWidth-40, 280);
    [byStartSwitch addTarget:self action:@selector(stateChanged:) forControlEvents:UIControlEventValueChanged];
    [self.bottomView addSubview:byStartSwitch];
    JTMaterialSwitch *bbSwitch = [[JTMaterialSwitch alloc] initWithSize:JTMaterialSwitchSizeNormal
                                                                           style:JTMaterialSwitchStyleDefault
                                                                           state:JTMaterialSwitchStateOn];
    bbSwitch.tag=105;
    bbSwitch.center = CGPointMake(kScreenWidth-40, 382);
    [bbSwitch addTarget:self action:@selector(stateChanged:) forControlEvents:UIControlEventValueChanged];
    [self.bottomView addSubview:bbSwitch];
    
    JTMaterialSwitch *s8Switch = [[JTMaterialSwitch alloc] initWithSize:JTMaterialSwitchSizeNormal
                                                                  style:JTMaterialSwitchStyleDefault
                                                                  state:JTMaterialSwitchStateOn];
    s8Switch.tag=106;
    s8Switch.center = CGPointMake(kScreenWidth-40, 433);
    [s8Switch addTarget:self action:@selector(stateChanged:) forControlEvents:UIControlEventValueChanged];
    [self.bottomView addSubview:s8Switch];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewDidAppear:animated];
     self.navigationController.navigationBarHidden =NO;
} 
-(void)stateChanged:(id)sender{
    JTMaterialSwitch *switchButton = (JTMaterialSwitch*)sender;
   // switchButton.isOn
   // getSwitchState
    NSLog(@"%hhd",switchButton.isOn);
       NSLog(@"%hhd",switchButton.getSwitchState);
} 


- (void)dealloc
{
    NSLog(@"%s",__FUNCTION__);
}

- (void)todayItemClicked:(id)sender
{
    [_calendar setCurrentPage:[NSDate date] animated:YES];
    [self.calendar selectDate:[NSDate date]];
}

#pragma mark - <FSCalendarDelegate>

- (void)calendar:(FSCalendar *)calendar didSelectDate:(NSDate *)date
{
    
    NSLog(@"%s 111111%@", __FUNCTION__, [calendar stringFromDate:date format:@"yyyy/MM/dd"]);
}

- (void)calendarCurrentPageDidChange:(FSCalendar *)calendar
{
    NSLog(@"%s %@", __FUNCTION__, [calendar stringFromDate:calendar.currentPage format:@"MMMM yyyy dd"]);
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}

- (IBAction)sleep{}
- (IBAction)weight{}
- (IBAction)remark{}
@end
